﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;
using Project.Engine.Utilities;
using System.Web.SessionState;
using Project.Module.DAO.CMSBL;
using Project.Module.DAO.BL;

namespace Project.Module.Controller
{
    public class CMSManagerProductController
    {
    }

    public partial class HomeController {
        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult AddNewProduct(string name, string image, int quantity, int price, string description, int cateId, int supplierId, string displayAdmin)
        {
            (new ProductBL()).AddNewProduct(name, image, quantity, price, description, cateId, supplierId, displayAdmin);
            // return
            return Json(new { result = 0 }, JsonRequestBehavior.AllowGet); 
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public JsonResult EditProduct(int id, string name, string image, int quantity, int price, string description, int cateId, int supplierId, string displayAdmin)
        {
            (new ProductBL()).EditProduct(id, name, image, quantity, price, description, cateId, supplierId, displayAdmin);
            // return
            return Json(new { result = 0 }, JsonRequestBehavior.AllowGet);
        }

        public ActionResult DeleteProduct(int productId) {
            (new ProductBL()).DeleteProduct(productId);
            return Redirect("/admin/quan-ly-san-pham");
        }
    }
}
